﻿function btnCommit(){
	if($("cUsername").value == "") {
		alert("请输入帖子用户名");
		$("cUsername").focus();
		return ;
	}
	
	if($("cAddress").value == "") {
		alert("请输入帖地址");
		$("cAddress").focus();
		return ;
	}
	
	if($("cUsername").value.length > 32) {
		alert("用户名过长");
		$("cUsername").focus();
		return;
	}
	
	if($("cAddress").value.length > 512) {
		alert("地址过长");
		$("cAddress").focus();
		return;
	}
	
	if($("cMs").value.length > 512) {
		alert("描述过长");
		$("cMs").focus();
		return;
	}
	var nId = getParm("nId");
	if(isNaN(nId)){
		alert(nId);
		return;
	}
	var nRwbh = getParm("nRwbh");
	if(isNaN(nRwbh)){
		alert(nRwbh);
		return;
	}
	if(!confirm("确定要提交改帖子吗？"))return;
	var gcSave = new AjaxProxy();
	gcSave.addParm("nId",nId);
	gcSave.addParm("nRwbh",nRwbh);
	gcSave.addParm("cUsername",$("cUsername").value);
	gcSave.addParm("cAddress",$("cAddress").value);
	gcSave.addParm("cMs",$("cMs").value);
	gcSave.invoke("task.commitTask",false);
	var flag = gcSave.getString("PN_RET");
	if(flag != 0){
		alert(gcSave.getString("PC_MSG"));
	}else{
		alert("任务提交成功!");
	}
}

function getParm(name)
{
 var str=window.location.search;
 if (str.indexOf(name)!=-1)
 {
  var pos_start=str.indexOf(name)+name.length+1;
  var pos_end=str.indexOf("&",pos_start);
  if (pos_end==-1)
  {
   return str.substring(pos_start);
  }
  else
  {
   return str.substring(pos_start,pos_end)
  }
 }
 else
 {
  return "参数错误";
 }
}
